<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>处理头像</title>
    {include file="common/linkcss" /}
    <link rel="stylesheet" href="__STATIC__/cropper/cropper.min.css">
    <script src="__STATIC__/cropper/cropper.min.js"></script>
    <script src="__STATIC__/hammer/hammer.min.js"></script>
</head>

<body>
    <div id="cropper">
        <img id="image" src="http://5b0988e595225.cdn.sohucs.com/q_mini,c_zoom,w_640/images/20170818/56cae1c627f2481d824d51c1666e307c.jpeg">
    </div>

    <style>
        body,
        html {
            height: 100%;
        }

        #cropper {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
        }

        img {
            max-width: 100%;
        }
    </style>


    <script>
        var $image = $('#image');

        $image.cropper({
            aspectRatio: 10 / 10,
            dragMode: 'move',
            cropBoxMovable: false,
            cropBoxResizable: false,

            crop: function (event) {

            }
        });
        var cropper = $image.data('cropper');
        var cropperDiv = document.querySelector('#cropper');
        var hammertime = new Hammer(cropperDiv);
        hammertime.add(new Hammer.Rotate());
        var startRotate = 0;
        hammertime.on('rotateend', function (ev) {
            cropper.rotate(ev.rotation);
            startRotate = ev.rotation;
        });
    </script>
</body>

</html>